/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-10-12
 * Time: 14:59
 */
public class TestDemo {

    public static void move(char pos1,char pos2){
        System.out.print(pos1+"->"+pos2+" ");
    }
    public static void Hanoi(int n ,char pos1,char pos2,char pos3) {
        if(n==1) {
            move(pos1,pos3);
        }
        else{
            Hanoi(n-1,pos1,pos3,pos2);
            move(pos1,pos3);
            Hanoi(n-1,pos2,pos1,pos3);
        }
    }
    public static void main(String[] args) {
        Hanoi(1,'A','B','C');
        System.out.println();
        Hanoi(2,'A','B','C');
        System.out.println();
        Hanoi(3,'A','B','C');
    }
}
